/*
 * Filename:    PerformanceIndicatorsController.java
 * Copyright:   2014 中国平安保险（集团）股份有限公司 版权所有
 * Company:     平安科技养老险及健康险系统开发部
 * Create at:   2014-11-10
 */
package com.paic.mhis.hcpms.assessment.web;

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.paic.mhis.hcpms.agreement.healthcareprovider.util.HttpProcessUtil;
import com.paic.mhis.hcpms.assessment.biz.service.PerformanceIndicatorsService;
import com.paic.mhis.hcpms.warning.util.WarnConstants;
import com.paic.pafa.appclient.annotation.BizServicesProxy;

/**  
 * Description: 
 * @author:     EX-LUANDEBIAO001
 * @version:     
 */
@Controller
@RequestMapping("/assessment/")
public class PerformanceIndicatorsController {
	private static final Logger LOG = Logger
			.getLogger(PerformanceIndicatorsController.class);

	@BizServicesProxy(beanName = "performanceIndicatorsService")
	private PerformanceIndicatorsService performanceIndicatorsService;

	/**
	 * 
	 * Description:  通过指标体系编码判断有无使用过,来决定保存或修改数据  
	 * @param request
	 * @return
	 * @throws UnsupportedEncodingException
	 * @throws IOException
	 * 
	 * Modification History:  
	 * Date        Version       Author          Description  
	 * ------------------------------------------------------------------  
	 * 2015-2-27    mhis_hcpms     EX-LUANDEBIAO001     创建
	 */
	@RequestMapping("saveIndicators.do")
	@ResponseBody
	public Map<String, Object> saveIndicators(HttpServletRequest request) {
		Map<String, Object> result = null;
		// 获取参数
		try {
			String param = HttpProcessUtil.readRequestBody(request);
			result = performanceIndicatorsService.saveIndicators(param);
		} catch (Exception e) {
			LOG.error(e, e);
			result = HttpProcessUtil.processException(e);
		}

		return result;
	}

	/**
	 * 
	 * Description: 根据指标体系编码,查询具体指标   
	 * @param structureNo 指标体系编码
	 * @return
	 * 
	 * Modification History:  
	 * Date        Version       Author          Description  
	 * ------------------------------------------------------------------  
	 * 2015-2-27    mhis_hcpms     EX-LUANDEBIAO001     创建
	 */
	@RequestMapping("findIndicators.do")
	@ResponseBody
	public Map<String, Object> findIndicators() {
		Map<String, Object> result = new HashMap<String, Object>();

		try {
			Map<String, Object> map = performanceIndicatorsService
					.findIndicatorsByLevel();
			result.put(WarnConstants.SUCCESS_RESULT_KEY, map);
			result.put(WarnConstants.STATE_KEY,
					WarnConstants.SUCCESS_STATE_VALUE);
			result.put(WarnConstants.MSG_KEY, WarnConstants.SELECT_SUCCESS);
		} catch (Exception e) {
			LOG.error(e, e);
			result = HttpProcessUtil.processException(e);
		}

		return result;
	}

}
